package com.gsk.europepharma.salesReport.struts.actions;

import java.security.Principal;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.ForwardAction;

public class AccueilAction extends ForwardAction {
	
	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) 
			throws Exception {
		
		HttpSession sessionObject = request.getSession();
		
		// Utilisateur 
		Principal user = request.getUserPrincipal();
		
		// Admin  
		if (request.isUserInRole("FranceSalesReportAdmin")) {
			sessionObject.setAttribute("adminSR", "adminSR");
		} else {
			sessionObject.setAttribute("adminSR", "notAdminSR");
		}
		
		sessionObject.setAttribute("cs_adm_pdt", 0);
		
		return mapping.findForward("success");
	}

}
